package com.up.upzl.biz.domain;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Transient;

import com.up.upzl.base.domain.BaseDomain;

import lombok.Getter;
import lombok.Setter;

/**
 * 文章管理
 * 
 * @author joker
 *
 */
@Getter
@Setter
@Entity
public class Article extends BaseDomain {

	private static final long serialVersionUID = 2975635485835252855L;

	/**
	 * 封面
	 */
	@Column(length = 80)
	private String coverUrl;

	/**
	 * 展示标题
	 */
	@Column(length = 80)
	private String showTitle;

	/**
	 * 文章标题
	 */
	@Column(length = 80)
	private String title;

	/**
	 * 文章内容
	 */
	@Column(length = 80000)
	private String content;

	/**
	 * 来源
	 */
	@Column(length = 80)
	private String source;

	/**
	 * 所属二级分类
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "cat_id")
	private ArticleCategory articleCategory;

	/**
	 * 所属一级分类
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "one_cat_id")
	private ArticleCategory oneArticleCategory;

	/**
	 * APP创建人
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "user_id")
	private User user;

	/**
	 * 后台创建人
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "account_id")
	private SysAccount sysAccount;

	/**
	 * 是否报名 1:是 0:否
	 */

	private Boolean enroll;

	@Transient
	public String getEnrollText() {
		if (enroll) {
			return "是";
		} else {
			return "否";
		}
	}

	/**
	 * 是否留言 1:是 0:否
	 */
	private Boolean message;

	@Transient
	public String getMessageText() {
		if (message) {
			return "是";
		} else {
			return "否";
		}
	}

	/**
	 * 是否置顶 1:是 0:否
	 */
	private Boolean stick;

	@Transient
	public String getStickText() {
		if (stick) {
			return "是";
		} else {
			return "否";
		}
	}

	/**
	 * 是否发布 1:是 0:否
	 */
	private Boolean publish;

	@Transient
	public String getPublishText() {
		if (publish) {
			return "是";
		} else {
			return "否";
		}
	}

	/**
	 * 活动标题
	 */

	@Column(length = 80)
	private String activityTitle;

	/**
	 * 活动地点
	 */

	@Column(length = 80)
	private String activityAddress;

	/**
	 * 活动类型
	 */

	@Column(length = 80)
	private String activityType;

	/**
	 * 活动时间
	 */
	private Date activityTime;

	/**
	 * 活动负责人
	 */
	@Column(length = 80)
	private String activityUsername;

	/**
	 * 展示量
	 */
	private Integer showNumber;

	/**
	 * 真实点击量
	 */
	private Integer clickNumber;

	/**
	 * 虚拟点击量
	 */

	private Integer dummyClickNumber;

	/**
	 * 分享量
	 */

	private Integer shareNumber;

	/**
	 * 展示标识
	 */
	private Label label;

	public enum Label {
		精选, 优质, 优铺官方
	}

	/**
	 * 发布者来源
	 */
	private AddSource addSource;

	public enum AddSource {
		后台, APP
	}

	/**
	 * 审核
	 */

	private Auditing auditing;

	public enum Auditing {
		未审核, 通过, 拒绝
	}

	/**
	 * 排序
	 */
	private Long sort;

	/**
	 * 留言列表
	 */
	@OneToMany(mappedBy = "article", fetch = FetchType.LAZY)
	private List<Comment> Comments;

}
